#include <cm/net/cm_multicast.h>

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
void my_proc(const char *data, size_t size)
{
	printf("data from mcast: %s\n", data);
}

int main(int argc, char **argv)
{
	if (argc != 4) {
		printf("Usage: %s <group ip> <port> <local interface>\n",
				argv[0]);
		return 0;
	}

	cm_mcast *m = mcast_create(argv[1], argv[3],
			(unsigned short) atoi(argv[2]), my_proc);

	if (m == NULL)
		return 0;

	char buffer[1024];
	while (1) {
		printf("> ");
		memset(buffer, 0, 1024);
		fscanf(stdin, "%s", buffer);
		mcast_send(m, buffer, strlen(buffer));
	}
}
